package com.dx.esb.m8583.test;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;

import com.dx.esb.m8583.Parse8583;
import com.dx.esb.m8583.bean.M8583Bean;
import com.dx.esb.m8583.config.Config;
import com.dx.esb.m8583.map.FiledBean;

public class Test {
	public static void main(String[] args) throws Exception{
		String s8583="60 00 03 00 00 60 31 00 31 07 30 02 00 30 20 04 C0 20 C0 98 11 00 00 00 00 00 00 00 00 01 00 03 49 02 10 00 12 30 62 25 82 21 12 99 63 01 5D 15 11 10 10 00 00 35 36 38 35 32 33 31 34 32 33 35 32 31 34 35 32 36 38 35 39 32 33 36 31 35 36 C6 24 83 4D 36 7E 9E 9E 20 00 00 00 00 00 00 00 00 13 22 00 00 08 00 05 00 36 37 41 32 32 39 39 41";
		Config config=new Config();
		InputStream in=Test.class.getClassLoader().getResourceAsStream("com/primeton/esb/m8583/test/config.xml");
		System.out.println(in);
		config.parse(in);
		s8583=s8583.replaceAll(" ", "");
		Parse8583 parse=new Parse8583();
		parse.setConfig(config);
		M8583Bean mbean=parse.get8583Bean(s8583);
		/*System.out.println("tpdu="+mbean.getTpdu());
		System.out.println("header="+mbean.getHeader());
		System.out.println("type="+mbean.getType());
		System.out.println("bit="+mbean.getBit());
		System.out.println();
		List filedbean=mbean.getFiledList();
		for(int i=0;i<filedbean.size();i++){
			FiledBean filedBean=(FiledBean) filedbean.get(i);
			System.out.println("域"+filedBean.getDomain()+" value="+filedBean.getObj()+" "+filedBean.getType().name()+" "+filedBean.getLength()+" "+filedBean.getInfo()+" "+filedBean.getBcd());
		}*/
		
		/*Document dom=Parse8583.m8583ToXML(mbean);
		dom.setXMLEncoding("UTF-8");
		System.out.println(dom.asXML());*/
		
		String s8583test=parse.get8583String(mbean);
		System.out.println(s8583test);
	}
}
